import { BaseSeeder } from '@adonisjs/lucid/seeders'

import Dict from '#models/dict'
import Shop from '#models/shop'
import User from '#models/user'

export default class extends BaseSeeder {
  async run() {
    const shop = await Shop.create({
      name: '吧唧测试门店',
      level: 1,
      mobilePhone: '123',
    })

    await Dict.createMany([
      {
        fkShopId: shop.id,
        className: 'role',
        code: 'ADMIN',
        name: '系统管理员',
        isBuiltin: true,
      },
      {
        fkShopId: shop.id,
        className: 'role',
        code: 'DZ',
        name: '店长',
      },
      {
        fkShopId: shop.id,
        className: 'payment',
        code: 'RMB',
        name: '现金',
        isBuiltin: true,
      },
      {
        fkShopId: shop.id,
        className: 'payment',
        code: 'WX',
        name: '微信支付',
        isBuiltin: true,
      },
      {
        fkShopId: shop.id,
        className: 'payment',
        code: 'ZFB',
        name: '支付宝',
        isBuiltin: true,
      },
      {
        fkShopId: shop.id,
        className: 'role',
        code: 'SYY',
        name: '收银员',
      },
      {
        fkShopId: shop.id,
        className: 'dept',
        code: 'GLB',
        name: '管理部',
      },
      {
        fkShopId: shop.id,
        className: 'dept',
        code: 'YB',
        name: '一部',
      },
      // {
      //   fkShopId: shop.id,
      //   className: 'job',
      //   code: 'DZ',
      //   name: '店长',
      // },
      {
        fkShopId: shop.id,
        className: 'job',
        code: 'DY',
        name: '店员',
      },
      {
        fkShopId: shop.id,
        className: 'warehouse',
        code: '01',
        name: '总仓库',
      },
      {
        fkShopId: shop.id,
        className: 'warehouse',
        code: '02',
        name: '消耗仓库',
      },
      {
        fkShopId: shop.id,
        className: 'category',
        code: '001',
        name: '默认分类',
      },
      {
        fkShopId: shop.id,
        className: 'queueType',
        code: 'XJC',
        name: '洗剪吹',
        extra: {
          serviceDuration: 30,
        },
      },
      {
        fkShopId: shop.id,
        className: 'queueType',
        code: 'TRH',
        name: '烫染护',
        extra: {
          serviceDuration: 60,
        },
      },
      {
        fkShopId: shop.id,
        className: 'queueType',
        code: 'XF',
        name: '洗发',
        extra: {
          serviceDuration: 15,
        },
      },
    ])

    await User.create({
      fkShopId: shop.id,
      fkRoleId: 1,
      userName: 'admin',
      nickName: '系统管理员',
      password: '123456',
    })

    // await GoodsFactory.createMany(10)
  }
}
